// --------------------------------------------------------------------------------------------
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
// 
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
// 
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
// 
// <remarks>
// Generated by IDLImporter from file nsICachingChannel.idl
// 
// You should use these interfaces when you access the COM objects defined in the mentioned
// IDL/IDH file.
// </remarks>
// --------------------------------------------------------------------------------------------
namespace Gecko
{
	using System;
	using System.Runtime.InteropServices;
	using System.Runtime.InteropServices.ComTypes;
	using System.Runtime.CompilerServices;
	
	
	/// <summary>
    /// A channel may optionally implement this interface to allow clients
    /// to affect its behavior with respect to how it uses the cache service.
    ///
    /// This interface provides:
    /// 1) Support for "stream as file" semantics (for JAR and plugins).
    /// 2) Support for "pinning" cached data in the cache (for printing and save-as).
    /// 3) Support for uniquely identifying cached data in cases when the URL
    /// is insufficient (e.g., HTTP form submission).
    /// </summary>
	[ComImport()]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("dd1d6122-5ecf-4fe4-8f0f-995e7ab3121a")]
	public interface nsICachingChannel : nsICacheInfoChannel
	{
		
		/// <summary>
        /// Get expiration time from cache token. This attribute is equivalent to
        /// nsICachingChannel.cacheToken.expirationTime.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		new uint GetCacheTokenExpirationTimeAttribute();
		
		/// <summary>
        /// Set/get charset of cache entry. Accessing this attribute is equivalent to
        /// calling nsICachingChannel.cacheToken.getMetaDataElement("charset") and
        /// nsICachingChannel.cacheToken.setMetaDataElement("charset").
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		new void GetCacheTokenCachedCharsetAttribute([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase aCacheTokenCachedCharset);
		
		/// <summary>
        /// Set/get charset of cache entry. Accessing this attribute is equivalent to
        /// calling nsICachingChannel.cacheToken.getMetaDataElement("charset") and
        /// nsICachingChannel.cacheToken.setMetaDataElement("charset").
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		new void SetCacheTokenCachedCharsetAttribute([MarshalAs(UnmanagedType.LPStruct)] nsACStringBase aCacheTokenCachedCharset);
		
		/// <summary>
        /// TRUE if this channel's data is being loaded from the cache.  This value
        /// is undefined before the channel fires its OnStartRequest notification
        /// and after the channel fires its OnStopRequest notification.
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		new bool IsFromCache();
		
		/// <summary>
        /// Set/get the cache key... uniquely identifies the data in the cache
        /// for this channel.  Holding a reference to this key does NOT prevent
        /// the cached data from being removed.
        ///
        /// A cache key retrieved from a particular instance of nsICacheInfoChannel
        /// could be set on another instance of nsICacheInfoChannel provided the
        /// underlying implementations are compatible and provided the new
        /// channel instance was created with the same URI.  The implementation of
        /// nsICacheInfoChannel would be expected to use the cache entry identified
        /// by the cache token.  Depending on the value of nsIRequest::loadFlags,
        /// the cache entry may be validated, overwritten, or simply read.
        ///
        /// The cache key may be NULL indicating that the URI of the channel is
        /// sufficient to locate the same cache entry.  Setting a NULL cache key
        /// is likewise valid.
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		new nsISupports GetCacheKeyAttribute();
		
		/// <summary>
        /// Set/get the cache key... uniquely identifies the data in the cache
        /// for this channel.  Holding a reference to this key does NOT prevent
        /// the cached data from being removed.
        ///
        /// A cache key retrieved from a particular instance of nsICacheInfoChannel
        /// could be set on another instance of nsICacheInfoChannel provided the
        /// underlying implementations are compatible and provided the new
        /// channel instance was created with the same URI.  The implementation of
        /// nsICacheInfoChannel would be expected to use the cache entry identified
        /// by the cache token.  Depending on the value of nsIRequest::loadFlags,
        /// the cache entry may be validated, overwritten, or simply read.
        ///
        /// The cache key may be NULL indicating that the URI of the channel is
        /// sufficient to locate the same cache entry.  Setting a NULL cache key
        /// is likewise valid.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		new void SetCacheKeyAttribute([MarshalAs(UnmanagedType.Interface)] nsISupports aCacheKey);
		
		/// <summary>
        /// Set/get the cache token... uniquely identifies the data in the cache.
        /// Holding a reference to this token prevents the cached data from being
        /// removed.
        ///
        /// A cache token retrieved from a particular instance of nsICachingChannel
        /// could be set on another instance of nsICachingChannel provided the
        /// underlying implementations are compatible.  The implementation of
        /// nsICachingChannel would be expected to only read from the cache entry
        /// identified by the cache token and not try to validate it.
        ///
        /// The cache token can be QI'd to a nsICacheEntryInfo if more detail
        /// about the cache entry is needed (e.g., expiration time).
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsISupports GetCacheTokenAttribute();
		
		/// <summary>
        /// Set/get the cache token... uniquely identifies the data in the cache.
        /// Holding a reference to this token prevents the cached data from being
        /// removed.
        ///
        /// A cache token retrieved from a particular instance of nsICachingChannel
        /// could be set on another instance of nsICachingChannel provided the
        /// underlying implementations are compatible.  The implementation of
        /// nsICachingChannel would be expected to only read from the cache entry
        /// identified by the cache token and not try to validate it.
        ///
        /// The cache token can be QI'd to a nsICacheEntryInfo if more detail
        /// about the cache entry is needed (e.g., expiration time).
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void SetCacheTokenAttribute([MarshalAs(UnmanagedType.Interface)] nsISupports aCacheToken);
		
		/// <summary>
        /// The same as above but accessing the offline app cache token if there
        /// is any.
        ///
        /// @throws
        /// NS_ERROR_NOT_AVAILABLE when there is not offline cache token
        /// </summary>
		[return: MarshalAs(UnmanagedType.Interface)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		nsISupports GetOfflineCacheTokenAttribute();
		
		/// <summary>
        /// The same as above but accessing the offline app cache token if there
        /// is any.
        ///
        /// @throws
        /// NS_ERROR_NOT_AVAILABLE when there is not offline cache token
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void SetOfflineCacheTokenAttribute([MarshalAs(UnmanagedType.Interface)] nsISupports aOfflineCacheToken);
		
		/// <summary>
        /// Instructs the channel to only store the metadata of the entry, and not
        /// the content. When reading an existing entry, this automatically sets
        /// LOAD_ONLY_IF_MODIFIED flag.
        /// Must be called before asyncOpen().
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetCacheOnlyMetadataAttribute();
		
		/// <summary>
        /// Instructs the channel to only store the metadata of the entry, and not
        /// the content. When reading an existing entry, this automatically sets
        /// LOAD_ONLY_IF_MODIFIED flag.
        /// Must be called before asyncOpen().
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void SetCacheOnlyMetadataAttribute([MarshalAs(UnmanagedType.U1)] bool aCacheOnlyMetadata);
		
		/// <summary>
        /// Tells the channel to use the pinning storage.
        /// </summary>
		[return: MarshalAs(UnmanagedType.U1)]
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		bool GetPinAttribute();
		
		/// <summary>
        /// Tells the channel to use the pinning storage.
        /// </summary>
		[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
		void SetPinAttribute([MarshalAs(UnmanagedType.U1)] bool aPin);
	}
	
	/// <summary>nsICachingChannelConsts </summary>
	public class nsICachingChannelConsts
	{
		
		// <summary>
        // This load flag inhibits fetching from the net.  An error of
        // NS_ERROR_DOCUMENT_NOT_CACHED will be sent to the listener's
        // onStopRequest if network IO is necessary to complete the request.
        //
        // This flag can be used to find out whether fetching this URL would
        // cause validation of the cache entry via the network.
        //
        // Combining this flag with LOAD_BYPASS_LOCAL_CACHE will cause all
        // loads to fail. This flag differs from LOAD_ONLY_FROM_CACHE in that
        // this flag fails the load if validation is required while
        // LOAD_ONLY_FROM_CACHE skips validation where possible.
        // </summary>
		public const ulong LOAD_NO_NETWORK_IO = 1<<26;
		
		// <summary>
        // This load flag causes the offline cache to be checked when fetching
        // a request.  It will be set automatically if the browser is offline.
        //
        // This flag will not be transferred through a redirect.
        // </summary>
		public const ulong LOAD_CHECK_OFFLINE_CACHE = 1<<27;
		
		// <summary>
        // This load flag causes the local cache to be skipped when fetching a
        // request.  Unlike LOAD_BYPASS_CACHE, it does not force an end-to-end load
        // (i.e., it does not affect proxy caches).
        // </summary>
		public const ulong LOAD_BYPASS_LOCAL_CACHE = 1<<28;
		
		// <summary>
        // This load flag causes the local cache to be skipped if the request
        // would otherwise block waiting to access the cache.
        // </summary>
		public const ulong LOAD_BYPASS_LOCAL_CACHE_IF_BUSY = 1<<29;
		
		// <summary>
        // This load flag inhibits fetching from the net if the data in the cache
        // has been evicted.  An error of NS_ERROR_DOCUMENT_NOT_CACHED will be sent
        // to the listener's onStopRequest in this case.  This flag is set
        // automatically when the application is offline.
        // </summary>
		public const ulong LOAD_ONLY_FROM_CACHE = 1<<30;
		
		// <summary>
        // This load flag controls what happens when a document would be loaded
        // from the cache to satisfy a call to AsyncOpen.  If this attribute is
        // set to TRUE, then the document will not be loaded from the cache.  A
        // stream listener can check nsICachingChannel::isFromCache to determine
        // if the AsyncOpen will actually result in data being streamed.
        //
        // If this flag has been set, and the request can be satisfied via the
        // cache, then the OnDataAvailable events will be skipped.  The listener
        // will only see OnStartRequest followed by OnStopRequest.
        // </summary>
        public const ulong LOAD_ONLY_IF_MODIFIED = (ulong)1 << 31;
	}
}
